$(function () {
    $("#page").load("/back/page.html");
    findAll();
});
function findAll() {
    let data ={};
    data.id=$("#id").val();
    data.name=$("#name").val();
    data.pageSize = $.trim($("#pageSize").val());
    data.pageNum = $.trim($("#pageNum").val());
    $.ajax({
        url: '/back/order/findAllNav',
        data: data,
        type: 'get',
        dataType: 'json',
        success: function (data) {
            showNavs(data.list);
            $("#pageCount").html(data.number);
        }
    })
}
function showNavs(data) {
    let html = "";//定一个一个空得html
    for (let i = 0; i < data.length; i++) {
        html += '  <tr>\n' +
            '        <td>' + data[i].id + '</td>\n' +
            '        <td>' + data[i].name + '</td>\n' +
            '        <td>' + data[i].href + '</td>\n' +
            '   <td><a  href="javascript:edit( ' + data[i].id + ')">编辑</a> <a  href="javascript:dele( ' + data[i].id + ')">删除</a></td>\n' +
            '    </tr>';
    }
    $("#navFindAll").html(html);//赋值
}

function edit(id) {
    localStorage.setItem("navId", id);
    //sessionStorage.setItem("id",id);   本地存储  两种方式都可以
    $('#right').load('/back/nav/navEdit.html');//页面跳转
}

function dele(id) {
    $.ajax({
        url: '/back/nav/delete',
        data: {id: id},
        type: 'get',
        dataType: 'json',
        success: function (data) {
            if (data.result === 1) {
                $("#right").load('/back/nav/navManage.html');
            } else {
                alert("删除失败")
            }
        }
    })

}